package org.itydl.game.model

import org.itheima.kotlin.game.core.Painter
import org.itydl.game.Config
import org.itydl.game.business.Destoryable

/**
 * 被击打效果
 * 32张图片的组合
 */
class Blast(override val x: Int, override val y: Int) : Destoryable {

    // 就被销毁能力
    override val width: Int = Config.block
    override val height: Int = Config.block

    /**
     * 爆炸效果的32张图片
     */
    private val imagePaths = arrayListOf<String>()

    private var index: Int = 0

    init {
        (1..32).forEach {
            imagePaths.add("img/blast_$it.png")
        }
    }

    override fun draw() {
        index %= imagePaths.size
        Painter.drawImage(imagePaths[index], x, y)
        index ++
    }

    override fun isDestory(): Boolean {
        return index >= imagePaths.size
    }
}